package neuron.library.ga.common;


import java.util.ArrayList;

/*
 * TODO: Comment!!
 */
public abstract class AbstractChromosome implements Comparable<AbstractChromosome> {
	
	/*
	 * Score of chromosome.
	 */
	protected int score;
	
	
	// TODO: comment
	public abstract Object getGenes();
	public abstract void setGenes(Object genes);
	
	/*
	 * Setter and getter for score field.
	 */
	public void setScore(int score) {
		this.score = score;
	}
	public int getScore() {
		return score;
	}
	
	/*
	 * Perform mutation for current chromosome. 
	 * Will be realized in child strategies.
	 */
	public abstract void performMutation();
	
	/*
	 * Generate new child chromosomes. 
	 * Will be realized in child strategies.
	 */
	public abstract ArrayList<AbstractChromosome> performCrossover(AbstractChromosome chromosome);
	
	/*
	 * (non-Javadoc)
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	public int compareTo(AbstractChromosome chromosome) {
		// Better chromosome in first place in array. Therefore, the signs are turned.
		if (this.getScore() > chromosome.getScore())
			return -1;
		else if (this.getScore() < chromosome.getScore()) {
			return 1;
		}
		else {
			return 0;
		}
	}
}
